﻿using System;
using System.Data;
using DCEdu;

public partial class Contract : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack) return;
        if (Request.QueryString["id"] == null) return;
        
        ContractHistory contract = new ContractHistory();
        DataSet dataSetContract = contract.Get(Int32.Parse(Request.QueryString["id"]));
        DataSet dataSetTutor = new TutorProfile().Get(Int32.Parse(dataSetContract.Tables[0].Rows[0]["TutorID"].ToString()));
        DataSet dataSetCustomer = new Customers().Get(Int32.Parse(dataSetContract.Tables[0].Rows[0]["CusID"].ToString()));
        if (dataSetContract == null) return;

        if (dataSetContract.Tables[0].Rows.Count < 0) return;

        txtContClass.Text = dataSetContract.Tables[0].Rows[0]["Class"].ToString();        
        txtContDay.Text = dataSetContract.Tables[0].Rows[0]["ContractDate"].ToString();
        txtContEndHour.Text = dataSetContract.Tables[0].Rows[0]["EndHour"].ToString();
        txtContNumber.Text = dataSetContract.Tables[0].Rows[0]["ContractNumber"].ToString();
        txtContPlace.Text = dataSetContract.Tables[0].Rows[0]["Place"].ToString();
        txtContPrice.Text = dataSetContract.Tables[0].Rows[0]["ContractPrice"].ToString();
        txtContPupil.Text = dataSetContract.Tables[0].Rows[0]["PupilNumber"].ToString();
        txtContStartHour.Text = dataSetContract.Tables[0].Rows[0]["StartHour"].ToString();
        txtContSubj.Text = dataSetContract.Tables[0].Rows[0]["Subjects"].ToString();
        txtCurMark.Text = dataSetContract.Tables[0].Rows[0]["BeforeContractMark"].ToString();
        txtExpMark.Text = dataSetContract.Tables[0].Rows[0]["ExpectedMark"].ToString();
        txtFirstPaid.Text = dataSetContract.Tables[0].Rows[0]["TheFirstPaid"].ToString();
        txtSecondPaid.Text = dataSetContract.Tables[0].Rows[0]["TheSecondPaid"].ToString();
        txtStartDate.Text = dataSetContract.Tables[0].Rows[0]["StartDate"].ToString();
        tbxFile.Text = dataSetContract.Tables[0].Rows[0]["ContractFile"].ToString();
        tbxIsPaid.Text = dataSetContract.Tables[0].Rows[0]["isPaid"].ToString();
        tbxStatus.Text = dataSetContract.Tables[0].Rows[0]["Status"].ToString();

        lblCusAdd.Text = dataSetCustomer.Tables[0].Rows[0]["Address"].ToString();
        lblCusID.Text = dataSetCustomer.Tables[0].Rows[0]["ID"].ToString();
        lblCusName.Text = dataSetCustomer.Tables[0].Rows[0]["Name"].ToString();
        lblCusPhone.Text = dataSetCustomer.Tables[0].Rows[0]["Telephone"].ToString();

        lblTutorAdd.Text = dataSetTutor.Tables[0].Rows[0]["Address"].ToString();
        lblTutorID.Text = dataSetTutor.Tables[0].Rows[0]["IDNumber"].ToString();
        lblTutorName.Text = dataSetTutor.Tables[0].Rows[0]["Name"].ToString();
        lblTutorPhone.Text = dataSetTutor.Tables[0].Rows[0]["Phone"].ToString();
        
            
    }
}